package com.hotel.homehotel.before.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hotel.homehotel.before.entiy.Notice;
import com.hotel.homehotel.before.mapper.NoticeMapper;
import com.hotel.homehotel.before.service.NoticeService;
import com.hotel.homehotel.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
@Service
public class NoticeServiceImpl  implements NoticeService {
     @Autowired
    NoticeMapper noticeMapper;
    public List<Notice> getAllNews(){

        QueryWrapper<Notice>  queryWrapper=new QueryWrapper();

        queryWrapper.eq("notice_type","新闻");
        return  noticeMapper.selectList(queryWrapper);
    }
    public Notice getNoticeById(String id){
        return  noticeMapper.selectById(id);
    }

    public   boolean insert(  Notice notice){
        System.out.println(notice);
         return noticeMapper.insert(notice)>0;  //大于0插入成功
    }
    public List<Notice> getRim() {
        QueryWrapper<Notice>  queryWrapper=new QueryWrapper();

        queryWrapper.eq("notice_type","轮播图");
        return  noticeMapper.selectList(queryWrapper);

    }

    public   boolean delete(  String id){
        return noticeMapper.deleteById(id)>0;  //大于0插入成功
    }
    public   boolean update(  Notice notice){
        System.out.println(notice);
        return noticeMapper.updateById(notice)>0;   //大于0插入成功
    }

}
